﻿@{
    ViewBag.Title = "Search";
}


<link href="@Url.Content("~/Content/themes/ui-lightness/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
@*<link href="@Url.Content("~/Content/jqGrid/jquery-ui-jqgrid.css")" rel="stylesheet" type="text/css" />*@
<link href="@Url.Content("~/Content/jqGrid/ui.jqgrid.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jqGrid-4.3.1/js/i18n/grid.locale-en.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jqGrid-4.3.1/jquery.jqGrid.js")" type="text/javascript"></script>


<h2>Search</h2>
@{
    var grid = new Lib.Web.Mvc.JQuery.JqGrid.JqGridHelper<Stertex.Models.ProfileViewModel>("Profiles",
    dataType: Lib.Web.Mvc.JQuery.JqGrid.JqGridDataTypes.Json,
    methodType: Lib.Web.Mvc.JQuery.JqGrid.JqGridMethodTypes.Post,
    pager: true,
    rowsNumber: 10,
    width:920,
    dataString:"x=454",
   caption: "Search profile",
    sortingName: "Id",
    sortingOrder: Lib.Web.Mvc.JQuery.JqGrid.JqGridSortingOrders.Asc,
    url: Url.Action("GetResults"),
    viewRecords: true
  ).Navigator(new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorOptions() { Search = true, View = false },
    editActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorActionOptions() { Url = Url.Action("UpdateProfile")},// OnInitializeForm = "$.onInitializeForm", AfterShowForm = "$.onAfterShowForm", OnClose = "$.onClose" },
    addActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorActionOptions() { Url = Url.Action("AddProfile"), OnInitializeForm = "$.onInitializeForm", AfterShowForm = "$.onAfterShowForm", OnClose = "$.onClose" },
    deleteActionOptions: new Lib.Web.Mvc.JQuery.JqGrid.JqGridNavigatorActionOptions() { Url = Url.Action("DeleteProfile") }
  );
    
}

@grid.GetHtml()

<script type="text/javascript">
  $(document).ready(function () {
    var search_result_grid = null;

      setTimeout(function () {
           search_result_grid =     @grid.GetJavaScript()

           search_result_grid.setGridParam ({postData  :{xxx:'yyy'} });
        }, 1000);
  });

  $.onInitializeForm = function(formSelector){
        //alert(formSelector);
    }

    $.onAfterShowForm = function(formSelector) {
       
    }
</script>
